package com.hailiao.beidou.message.bd.ble

/**
 * 蓝牙设备管理
 * @Author d10ng
 * @Date 2023/11/17 10:10
 */
object BLEDeviceManager {

    // 连接的设备类型
    private var device: IBLEDevice? = null

    /**
     * 通过蓝牙名称获取设备
     * @param name String
     * @return IBLEDevice?
     */
    fun getDevice(name: String): IBLEDevice? {
        return when {
            H1301Device.instantOf(name) -> H1301Device
            H1302EDevice.instantOf(name) -> H1302EDevice
            V3001Device.instantOf(name) -> V3001Device
            H4Device.instantOf(name) -> H4Device
            C1Device.instantOf(name) -> C1Device
            B2Device.instantOf(name) -> B2Device
            else -> null
        }
    }

    fun setConnectedDevice(device: IBLEDevice?) {
        this.device = device
    }

    fun getConnectedDevice() = device
}